package JavaPractice;

import java.util.Scanner;
import java.util.Arrays;

public class GraphInheritAndMultistatus {
    public static void main(String args[]) {
        int c, r, t;
        int p = 0;
        double sumarea;
        Scanner reader = new Scanner(System.in);
        Circle circles[];
        Rectangle rectangles[];
        Triangle triangles[];
        double areas[];
        c = reader.nextInt();
        circles = new Circle[c];
        r = reader.nextInt();
        rectangles = new Rectangle[r];
        t = reader.nextInt();
        triangles = new Triangle[t];
        /*
        // 全为0， 直接Wrong Format
        if(c+r+t == 0)
        {
            System.out.println("Wrong Format");
            reader.close();
            System.exit(0);
        }
        */
        areas = new double[c + r + t];
        for (int i = 0; i < c; i++) {
            circles[i] = new Circle(reader.nextDouble());
            areas[p] = circles[i].getArea();
            p++;
        }
        for (int i = 0; i < r; i++) {
            rectangles[i] = new Rectangle(reader.nextDouble(), reader.nextDouble());
            areas[p] = rectangles[i].getArea();
            p++;
        }
        for (int i = 0; i < t; i++) {
            triangles[i] = new Triangle(reader.nextDouble(), reader.nextDouble(), reader.nextDouble());
            areas[p] = triangles[i].getArea();
            p++;
        }
        System.out.println("Original area:");
        sumarea = 0.0;
        for (int i = 0; i < p; i++) {
            sumarea += areas[i];
            System.out.printf("%.2f ", areas[i]);
        }
        System.out.printf("\n");
        System.out.printf("Sum of area:%.2f\n", sumarea);
        Arrays.sort(areas);
        sumarea = 0.0;
        System.out.println("Sorted area:");
        for (int i = 0; i < p; i++) {
            sumarea += areas[i];
            System.out.printf("%.2f ", areas[i]);
        }
        System.out.printf("\n");
        System.out.printf("Sum of area:%.2f\n", sumarea);
        reader.close();
    }
}

class Graph {
    void check(double... numbers) {
        for (double d : numbers) {
            if (d <= 0) {
                printErrorMessageAndExit();
            }
        }
    }

    void printErrorMessageAndExit() {
        System.out.println("Wrong Format");
        System.exit(0);
    }
}

class Circle extends Graph {
    private double radius, area;

    Circle(double r) {
        setParameter(r);
    }

    double getRadius() {
        return this.radius;
    }

    double getArea() {
        return this.area;
    }

    void setParameter(double r) {
        if(r==0){
            printErrorMessageAndExit();
        }
        this.radius = r;
        this.area = 3.1415926 * r * r;
    }
}

class Rectangle extends Graph {
    private double width, height, area;

    Rectangle(double w, double h) {
        setParameter(w, h);
    }

    double getWidth() {
        return this.width;
    }

    double getHeight() {
        return this.height;
    }

    double getArea() {
        return this.area;
    }

    void setParameter(double w, double h) {
        super.check(w, h);
        this.width = w;
        this.height = h;
        this.area = w * h;
    }
}

class Triangle extends Graph {
    private double edges[] = new double[3];
    private double area;

    Triangle(double... numbers) {
        setParameter(numbers);
    }

    double getArea() {
        return this.area;
    }

    void check(double... numbers) {
        super.check(numbers);
        Arrays.sort(numbers);
        if (numbers[0] + numbers[1] <= numbers[2]) {
            super.printErrorMessageAndExit();
        }
    }

    void setParameter(double... numbers) {
        check(numbers);
        for (int i = 0; i < 3; i++) {
            this.edges[i] = numbers[i];
        }
        double s = (edges[0] + edges[1] + edges[2]) / 2;
        this.area = Math.sqrt(s * (s - edges[0]) * (s - edges[1]) * (s - edges[2]));
    }
}